#version 430

in vec3 worldPos;
in vec3 worldNormal;
in vec2 texcoord;

out vec4 fragColor;

uniform vec3 cameraPos;
uniform vec3 lightDir;

void main()
{
	vec3 normal = normalize(worldNormal);
	vec3 viewDir = normalize(cameraPos - worldPos);


	vec3 ambient = vec3(0.5, 0.5, 0.5);

	vec3 lightDirection = normalize(-lightDir);
	vec3 diffuse = max(dot(lightDirection, normal), 0.0) * vec3(0.5, 0.5, 0.5);

	vec3 fake_light = vec3(-lightDirection.x, lightDirection.y, lightDirection.z);
	vec3 diffuse_1 = max(dot(fake_light, normal), 0.0) * vec3(0.5, 0.5, 0.5);

	vec3 reflect = normalize(reflect(-lightDirection, normal));
	vec3 specular = pow(max(dot(viewDir, reflect), 0.0), 1000) * vec3(1, 1, 1);

	fragColor = vec4(ambient + 0.5 * diffuse + 0.5*diffuse_1 + specular, 1.0f);
}